﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using Quartz;
using ZHDJ.Core.Log;
using ZHDJ.Data;
using ZHDJ.Data.BLL;
using ZHDJ.Data.Models.Common;
using ZHDJ.WinService.Util;
using MySqlHelper = ZHDJ.Data.MySqlHelper;

namespace ZHDJ.WinService.Job
{
    /// <summary>
    /// 考试系统用户同步
    /// </summary>
    public class ExamUserSyncJob : JobBase
    {
        /// <summary>
        /// 执行业务锁
        /// </summary>
        private static Object BusinessLock = new Object();
        public override JobSetInfo JobSetInfo
        {
            get
            {
                return new JobSetInfo()
                {
                    JobGroup = "ExamUserSyncJobGroup",
                    JobName = "ExamUserSyncJob",
                    //
                    TriggerName = "ExamUserSyncJobTrigger",
                    Cron = ConfigHelper.ExamUserSyncJobIntervalCron
                };
            }
        }


        public override void RunBusiness(IJobExecutionContext context)
        {
            LogHelper.Info(ConfigHelper.ExamUserSyncJobIntervalCron, "ExamUserSyncJob");
            //LogHelper.Info("组织关系重置--开始");
            lock (BusinessLock)
            {
                
                    LogHelper.Info("同步测评系统用户、学分--开始", "ExamUserSyncJob");
                    OnlineStudySystem.SyncData();
                    OnlineStudySystem.SyncStudyFen();
                    OnlineStudySystem.SyncExamFen();
                    LogHelper.Info("同步测评系统用户、学分--结束", "ExamUserSyncJob");
                

            }
        }
        
    }
}
